<!--
 * @Author: fengweicong 75202172+fengweicong@users.noreply.github.com
 * @Date: 2022-06-29 17:29:14
 * @LastEditors: fengweicong 75202172+fengweicong@users.noreply.github.com
 * @LastEditTime: 2022-07-15 18:11:38
 * @FilePath: \B2B\ebuy\src\views\Main\Supplier\product\BarginHistory\index.vue
 * @Description: 
 * 
 * Copyright (c) 2022 by fengweicong 75202172+fengweicong@users.noreply.github.com, All Rights Reserved. 
-->
<template>
    <div class="barginHistory">
        <el-table
            :data="bargainData"
            style="width: 100%">
            <el-table-column
            prop="order_end_time"
            label="时间">
            </el-table-column>
            <el-table-column
            prop="purchaser_name"
            label="采购商">
            </el-table-column>
            <el-table-column
            prop="product_specification"
            label="规格">
            </el-table-column>
            <el-table-column
            prop="trade_volume"
            label="采购量">
            </el-table-column>
        </el-table>
    </div>
</template>

<script>
export default {
    data() {
        return {
            loading : false,
            reachBottom : false,
            bargainData:[],
        }
    },
    methods: {
        async load() {
            await this.$API.getProductOrder().then(res => {
                if (res.status == 200) {
                    for (let obj of res.data) {
                        if (obj.deal_status == 3) this.bargainData.push(obj)
                    }
                    return this.$API.getPurchaser()
                }
            }).then(res => {
                if (res.status == 200) {
                    for (let obj of res.data) {
                        for (let obj2 of this.bargainData) {
                            if (obj.id == obj2.purchaser_id) obj2['purchaser_name'] = obj.name
                        }
                    }
                    return this.$API.getSpecification()
                }
            }).then(res => {
                if (res.status == 200) {
                    for (let obj of res.data) {
                        for (let obj2 of this.bargainData) {
                            if (obj.id == obj2.product_specification_id) {
                                obj2['product_specification'] = obj.price + '元/' + obj.name
                                obj2.trade_volume += obj.name
                            }
                        }
                    }
                }
            })
        }
    },
    created() {
        this.load()
    }
}
</script>

<style lang="less" scoped>


</style>